package com.grass.finding.common;

import com.grass.finding.exception.BusinessException;
import lombok.Data;

@Data
public class BaseResponse<T> {
    private int code;
    private T data;
    private String message;
    private String description;

    public BaseResponse(int code, T t, String message, String description) {
        this.code = code;
        this.data = t;
        this.message = message;
        this.description = description;
    }

    public BaseResponse(BusinessException e) {
        this.code = e.getCode();
        this.data = null;
        this.message = e.getMessage();
        this.description = e.getDescription();
    }

    public BaseResponse(ErrorCode error) {
        this.code = error.getCode();
        this.description = error.getDescription();
        this.message = error.getMessage();
        this.data = null;
    }
}
